package info.liuxing.okhttp.interceptor;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

/**
 * 添加默认的headers
 *
 * @author liuxing (SE)
 * @summary 添加默认的headers
 * @Copyright (c) 2017, Lianjia Group All Rights Reserved.
 * @since 2017-12-01 00:54
 */
public class DefaultHeadersInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request.Builder builder = chain.request().newBuilder();

        builder.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36");
//        builder.addHeader("Accept-Encoding", "gzip,deflate");
        builder.addHeader("Accept-Language", "zh-CN,zh;q=0.8,en;q=0.6");
        builder.addHeader("Connection", "keep-alive");
        
        return chain.proceed(builder.build());
    }
}
